Skip to content

Make Solr heap tunable via SOLR_HEAP (default 4g, no behavior change)#1309

Open
vidiecan wants to merge 1 commit into
dtq-devfrom
infra/tunable-solr-heap
Open

Make Solr heap tunable via SOLR_HEAP (default 4g, no behavior change)#1309
vidiecan wants to merge 1 commit into
dtq-devfrom
infra/tunable-solr-heap

Conversation

@vidiecan

@vidiecan vidiecan commented Jun 12, 2026

Copy link
Copy Markdown

What

Make the Solr JVM heap configurable via a SOLR_HEAP environment variable instead of the hardcoded -m 4g in the dspacesolr entrypoint.

-      exec solr -p 8983 -f -m 4g
+      exec solr -p 8983 -f -m ${SOLR_HEAP:-4g}

Default is unchanged (4g) — with no SOLR_HEAP set, behavior is identical to today, so this is safe everywhere. This mirrors the pattern already used for the backend Tomcat heap in the same file (JAVA_OPTS: ${JAVA_OPTS:--Xmx4g}).

Why

-m 4g makes Solr start with -Xms4g -Xmx4g, and because the Solr image runs with -XX:+AlwaysPreTouch, the full 4 GB is committed at container start — regardless of how small the index actually is.

On hosts that run a single stack this is fine. But on shared multi-stack dev boxes it is the dominant memory cost. Example: dev-5.pc runs 6 DSpace stacks (customer-uk, zcu-pub, lindat, TUL, dspace-7_x, zcu-data) on 31 GB of RAM. Six Solr containers alone reserve 6 × 4 GB = 24 GB, which pushes the box permanently above 90% memory and into heavy swap — and trips the NewRelic RAM alerts continuously.

There is currently no way to lower the Solr heap without editing the tracked compose file, which the CI deploy re-checks-out and reverts on every run. This change provides a proper, persistent knob: low-RAM/dev hosts can set SOLR_HEAP in their --env-file (e.g. /opt/dspace-envs/.env.dspace.dev-5.*SOLR_HEAP=1g) while production deployments keep the 4g default.

How to use

In the deploy env file for an instance:

SOLR_HEAP=1g

start.sh already passes --env-file, so compose interpolates it into the entrypoint at up time. Verified locally on dev-5.pc (instance 6): -m 1g → Solr RSS dropped from ~2.2 GB to ~430 MB.

Backport

This is a single, non-breaking line and should be backported to all customer/* branches so every customer deployment gains the knob (labelled accordingly).

Summary by CodeRabbit

  • Chores
    • Solr Docker service now supports configurable heap memory allocation via environment variable, with a 4GB default.

Default stays 4g, so no behavior change unless SOLR_HEAP is set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vidiecan vidiecan added the backport-to-customers Should be cherry-picked/backported to all customer/* branches label Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 72f1e033-e205-46b0-b293-8075a697d4ed

📥 Commits

Reviewing files that changed from the base of the PR and between 2b87775 and 27253a3.

📒 Files selected for processing (1)
  • docker/docker-compose-rest.yml

📝 Walkthrough

Walkthrough

The Docker Compose configuration for the dspacesolr service is updated to make the Solr JVM heap size configurable. The startup command now accepts a SOLR_HEAP environment variable with a 4-gigabyte default fallback instead of hardcoding the heap size.

Changes

Configurable Solr Heap Size

Layer / File(s) Summary
Solr heap configuration
docker/docker-compose-rest.yml
The dspacesolr service entrypoint passes ${SOLR_HEAP:-4g} to the JVM instead of a static -m 4g flag, enabling operator-configurable memory allocation.

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: making Solr heap tunable via SOLR_HEAP with a default of 4g and no behavior change.
Description check ✅ Passed The pull request description is comprehensive and well-structured, clearly explaining the problem, solution, usage, and backport needs—though it does not follow the repository's template sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-customers Should be cherry-picked/backported to all customer/* branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants